<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/view/common/easycommon.jsp"%>
<!DOCTYPE html>
<html>
<head>
    <title>数据字典管理界面</title>
    <meta charset="utf-8">
    <style>
    	html, body{ margin:0; height:100%; }
    	table{font-size:14px;border: 1px solid #DDDDDD;border-collapse:collapse;}
    	td{padding:5px;border: 1px solid #DDDDDD}
    	.input{width:250px;margin:4px;height:35;border: 1px solid #ccc;font-size:18px;border-radius:4px}
    	label{margin:4px}		
    	.btn{width:100px;height:35px;border-radius:4px;background:#6CAEF5;font-size:18px;margin:15px}
    	.sptit{font-size:28px;padding:25px}	
    </style>
    <script>
    
    $(function(){
    	var datagrid; //定义全局变量datagrid    
    	
        datagrid = $('#baseType').datagrid({
    		rownumbers:true,
    		singleSelect:true,
    		pagination:true,
    		//fit: true, //datagrid自适应宽度
            fitColumn: true, //列自适应宽度
            striped: true, //行背景交换
            nowap: false, //列内容多时自动折至第二行
            border: false,
            idField: 'id', //主键
            width:482,
            height:'98%',
    		url:"${path}/oaReport/income",
    		columns:[[
    			{field:'month',title:'月份',width:50,'sortable':true,fitColumns:true },    			
    			{field:'this_year_amount',title:'今年',width:100,'sortable':true,fitColumns:true },
    			{field:'last_year_amount',title:'去年',width:100,'sortable':true,fitColumns:true },
    			{field:'rate',title:'比例',width:100,'sortable':true,fitColumns:true },
    			{field:'increase_rate',title:'增长率',width:100,'sortable':true,fitColumns:true, 
    				formatter:function(value,rowData,rowIndex){
    					if(value!=null){
        					var a=value.substring(0,1) 
        					if(a=='-'){       						
        						return '<span style="color:green">'+value+'</span>';
        					}else{
        						return '<span style="color:red">'+value+'</span>';
        					}
        				}
    				}
    			}
    		]]
    	})
  
     var pager = datagrid.datagrid('getPager');   
    pager.pagination({
  	               total:2000,
  	               pageSize:10, 	
  	               pageNumber:1,
  	               pageList:[10,20,30],  	               
  	               loading:true,
  	               showPageList:true,
  	               showRefresh:true,
  	               beforePageText:'当前页数',
  	               afterPageText:' 共{pages}页',
  	               displayMsg:'共{total}条记录',  	           
  	           });   

	var cost; //定义全局变量datagrid    
	
	cost = $('#cost').datagrid({
		rownumbers:true,
		singleSelect:true,
		pagination:true,
		//fit: true, //datagrid自适应宽度
        fitColumn: true, //列自适应宽度
        striped: true, //行背景交换
        nowap: false, //列内容多时自动折至第二行
        border: false,
        idField: 'id', //主键
        width:482,
        height:'98%',
		url:"${path}/oaReport/cost",
		columns:[[
			{field:'month',title:'月份',width:50,'sortable':true,fitColumns:true },    			
			{field:'this_year_amount',title:'今年',width:100,'sortable':true,fitColumns:true },
			{field:'last_year_amount',title:'去年',width:100,'sortable':true,fitColumns:true },
			{field:'rate',title:'比例',width:100,'sortable':true,fitColumns:true },
			{field:'increase_rate',title:'增长率',width:100,'sortable':true,fitColumns:true, 
				formatter:function(value,rowData,rowIndex){
					if(value!=null){
    					var a=value.substring(0,1) 
    					if(a=='-'){       						
    						return '<span style="color:green">'+value+'</span>';
    					}else{
    						return '<span style="color:red">'+value+'</span>';
    					}
    				}
				}
			}
		]]
	})

 var pager = cost.datagrid('getPager');   
pager.pagination({
	               total:2000,
	               pageSize:10, 	
	               pageNumber:1,
	               pageList:[10,20,30],  	               
	               loading:true,
	               showPageList:true,
	               showRefresh:true,
	               beforePageText:'当前页数',
	               afterPageText:' 共{pages}页',
	               displayMsg:'共{total}条记录',  	           
	           });   


	$.ajax({
	 	url: "${path}/oaReport/totalData",    //请求的url地址
	 	dataType: "json",   //返回格式为json
	 	success: function(req) {
	 		if(req.status==0){
	 			$.messager.alert("错误", req.msg,"error"); 
	 		}else{
	 			var data=req.dataset;
	 			$('#yearIncome').html(data.yearIncome+'元');
	 			$('#yearPayment').html(data.yearPayment+'元');
	 			$('#yearContractIncome').html(data.yearContractIncome+'元');
	 			$('#yearContractCount').html(data.yearContractCount+'个');
	 			$('#yearNewUserCount').html(data.yearNewUserCount+'个');
	 		}
	    }
	});
    
    
})
</script>
</head>
<body>
	<span class="sptit">总计</span>
	<div  style="height:80px;margin:25px">
		<table>               
                <tr>
                    <td>
                        <span  class="tdsp1">年收入：</span>
                    </td>
                    <td>
                        <span  class="tdsp2" id="yearIncome"></span>
                    </td>
                    
                    <td>
                        <span  class="tdsp3">年度费用：</span>
                    </td>
                    <td>    
                    	<span  class="tdsp4" id="yearPayment"></span>                  
                    </td>
                </tr>
                <tr>
                    <td>
                        <span  class="tdsp1">年度签署合同/订单数：</span>
                    </td>
                    <td>
                        <span  class="tdsp2" id="yearContractIncome"></span>
                    </td>
                    
                    <td>
                        <span  class="tdsp3">年新增合同/订单：</span>
                    </td>
                    <td>    
                    	<span  class="tdsp4" id="yearContractCount"></span>                  
                    </td>
                </tr>
                <tr>
                    <td>
                        <span  class="tdsp1">年新增客户数量：</span>
                    </td>
                    <td>
                        <span  class="tdsp2" id="yearNewUserCount"></span>
                    </td>
                </tr>
                
         </table>

	</div>
	
	<span class="sptit">同期对比：元</span>
	<div></div>
	
	<div style="float:left;height:80%;margin:15px;width:482px">
 	<table id="baseType" title="合同/签订情况：（签约）" class="easyui-datagrid"
			singleSelect="true" iconCls="icon-save">
	</table>
	</div>
		<div style="float:left;height:80%;margin:15px;width:482px">
 	<table id="cost" title="费用情况：（审核通过）" class="easyui-datagrid"
			singleSelect="true" iconCls="icon-save">
	</table>
	</div>
	
</html>
